package com.telecom.cms.service;

import java.util.List;
import java.util.ArrayList;
import com.telecom.cms.dao.SEG_BIZ_ATOM_DEFDAO;
import com.telecom.cms.dto.SEG_BIZ_ATOM_DEFDTO;
import com.telecom.cms.dto.CampSeg;
import com.telecom.cms.dao.CampSegDAO;

public class SegBizAtomMgr {
   
	
	public List findall(){
		List result=(new SEG_BIZ_ATOM_DEFDAO()).findAll();
		return result;
	}
	
	public List findall(String clutype){
		List result=(new SEG_BIZ_ATOM_DEFDAO()).findAll(clutype);
		return result;
	}
	
	public List findallnouse(String campid){
		List result1=(new SEG_BIZ_ATOM_DEFDAO()).findAll();
		List result2=(new CampSegDAO()).findAll(campid);
		List result=new ArrayList();
		SEG_BIZ_ATOM_DEFDTO dto1=null;
		CampSeg dto2=null;
		boolean flag=false;

		for (int i=0;i<result1.size();i++)
		{
			dto1=(SEG_BIZ_ATOM_DEFDTO)result1.get(i);
			flag=false;
			for(int j=0;j<result2.size();j++)
			{
			  dto2=(CampSeg)result2.get(j);
			  if(dto2.getBizAtomId()==dto1.getBIZ_ATOM_ID())
				  flag=true;
			}
			if(!flag)
				result.add(dto1);
		}
		return result;
	}
	
	public List findareauseandnouse(String campid,String areaid,String clutype){
		List result1=(new SEG_BIZ_ATOM_DEFDAO()).findAll(clutype);
		List result2=(new CampSegDAO()).findAll(campid);
		List result=new ArrayList();
		SEG_BIZ_ATOM_DEFDTO dto1=null;
		CampSeg dto2=null;
		boolean flag=false;

		for (int i=0;i<result1.size();i++)
		{
			dto1=(SEG_BIZ_ATOM_DEFDTO)result1.get(i);
			flag=false;
			for(int j=0;j<result2.size();j++)
			{
			  dto2=(CampSeg)result2.get(j);
			  if(dto2.getShowAreaId()!=Integer.parseInt(areaid)&&dto2.getBizAtomId()==dto1.getBIZ_ATOM_ID())
				  flag=true;
			}
			if(!flag)
				result.add(dto1);
		}
		return result;
	}
	
}
